<?php
namespace app\payclass\controller;
use app\AdminRest;

use think\App;

use app\payclass\model\Order as model;

use think\facade\Db;


class AdminOrder extends AdminRest
{

    protected $model;

    public function __construct(App $app) {

        parent::__construct($app);

        $this->model = new Model();

    }


    /**
     * @author chenniang
     * @DataTime: 2020-09-29 11:35
     * @功能说明:列表
     */
    public function orderList(){

        $this->model->check($this->_uniacid);

        $input = $this->_param;

        $dis[] = ['a.uniacid','=',$this->_uniacid];

        if(!empty($input['title'])){

            $dis[] = ['b.title','like','%'.$input['title'].'%'];
        }

        if(!empty($input['pay_type'])){

            $dis[] = ['a.pay_type','=',$input['pay_type']];
        }

        if(!empty($input['start_time'])&&!empty($input['end_time'])){

            $start_time = $input['start_time'];

            $end_time   = $input['end_time'];

            $dis[] = ['a.create_time','between',"$start_time,$end_time"];
        }

        $data = $this->model->adminOrderList($dis,$input['limit']);

        return $this->success($data);

    }


    /**
     * @author chenniang
     * @DataTime: 2020-09-29 13:28
     * @功能说明:详情
     */
    public function orderInfo(){

        $input = $this->_param;

        $dis = [

            'id' => $input['id']
        ];

        $data = $this->model->orderInfo($dis);

        $data['nickName'] = Db::name('longbing_card_user')->where(['id'=>$data['user_id']])->value('nickName');

        $data['mobile']   = Db::name('longbing_card_user_phone')->where(['user_id'=>$data['user_id']])->value('phone');

        return $this->success($data);
    }








}
